<meta charset='utf-8'>
<?php
#	      	index:index,
#	      	MeiCiChou:J[index].MeiCiChou,
#	        k:zhongJiangHao,
#	        v:J[index].name

	function array2file()
	{
		$f = fopen($_POST['index'].'.txt', "a") or die("Unable to open file!");
		$myfile = fopen("YiChou.txt", "a") or die("Unable to open file!");
		$nums = explode(" ",$_POST['k']);
		foreach ($nums as $key => $value) {
			$value=trim($value);
			if(preg_match("/\s/i",$value)){
				continue;
			}
			$txt = " ".$value;
			fwrite($myfile, $txt);
			fwrite($f, $txt);
		}
		fclose($myfile);
		fclose($f);

		$file_name = "获奖名单.txt";
		$file_name=iconv("utf-8","gb2312",$file_name);
		$f = fopen($file_name, "a") or die("Unable to open file!");
		$txt = $_POST['v']."\t".$_POST['k']."\r\n";
		fwrite($f, $txt);
		fclose($f);

		#$myfile = fopen($file, "r") or die("Unable to open file : $file !");
		#while(!feof($myfile)) {
		#	$nums[]=fgets($myfile);
		#}
		#fclose($myfile);
		#return $nums;	
	}
	array2file();
?>